/*
 * RRSView.java
 * This form is the main for that controls the users 
 * operations.
 */

package rrs;

 
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
 /**
 * The application's main frame.
 */
public class RRSView extends FrameView 
{
    public RRSView(SingleFrameApplication app) 
    {
        super(app);
        initComponents();
            btnReports.setVisible(false);
            btnPurchase.setVisible(false);
            btnReturn.setVisible(false);
            lblSelect.setVisible(false); 
            btnActDeSystemID.setVisible(false);
            btnActDeCategoryID.setVisible(false);
            btnAddSystemScheme.setVisible(false);
            btnAddCategory.setVisible(false);
            btnAddCategory2.setVisible(false);
        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();       
    }    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        statusPanel = new javax.swing.JPanel();
        lblSelect = new javax.swing.JLabel();
        btnReports = new javax.swing.JButton();
        btnReturn = new javax.swing.JButton();
        btnPurchase = new javax.swing.JButton();
        btnInit = new javax.swing.JButton();
        TxtFile = new javax.swing.JTextField();
        lblMessage = new javax.swing.JLabel();
        lblBlank = new javax.swing.JLabel();
        btnActDeSystemID = new javax.swing.JButton();
        btnActDeCategoryID = new javax.swing.JButton();
        btnAddSystemScheme = new javax.swing.JButton();
        btnAddCategory = new javax.swing.JButton();
        btnAddCategory2 = new javax.swing.JButton();

        statusPanel.setMaximumSize(new java.awt.Dimension(5000, 5000));
        statusPanel.setName("statusPanel"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(rrs.RRSApp.class).getContext().getResourceMap(RRSView.class);
        lblSelect.setText(resourceMap.getString("lblSelect.text")); // NOI18N
        lblSelect.setName("lblSelect"); // NOI18N

        btnReports.setText(resourceMap.getString("btnReports.text")); // NOI18N
        btnReports.setAutoscrolls(true);
        btnReports.setEnabled(false);
        btnReports.setName("btnReports"); // NOI18N
        btnReports.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnReportsMouseClicked(evt);
            }
        });

        btnReturn.setText(resourceMap.getString("btnReturn.text")); // NOI18N
        btnReturn.setAutoscrolls(true);
        btnReturn.setEnabled(false);
        btnReturn.setName("btnReturn"); // NOI18N
        btnReturn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnReturnMouseClicked(evt);
            }
        });

        btnPurchase.setText(resourceMap.getString("btnPurchase.text")); // NOI18N
        btnPurchase.setAutoscrolls(true);
        btnPurchase.setEnabled(false);
        btnPurchase.setName("btnPurchase"); // NOI18N
        btnPurchase.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnPurchaseMouseClicked(evt);
            }
        });

        btnInit.setText(resourceMap.getString("btnInit.text")); // NOI18N
        btnInit.setAutoscrolls(true);
        btnInit.setName("btnInit"); // NOI18N
        btnInit.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnInitMouseClicked(evt);
            }
        });

        TxtFile.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        TxtFile.setText(resourceMap.getString("TxtFile.text")); // NOI18N
        TxtFile.setName("TxtFile"); // NOI18N

        lblMessage.setFont(resourceMap.getFont("lblMessage.font")); // NOI18N
        lblMessage.setText(resourceMap.getString("lblMessage.text")); // NOI18N
        lblMessage.setName("lblMessage"); // NOI18N

        lblBlank.setText(resourceMap.getString("lblBlank.text")); // NOI18N
        lblBlank.setName("lblBlank"); // NOI18N

        btnActDeSystemID.setText(resourceMap.getString("btnActDeSystemID.text")); // NOI18N
        btnActDeSystemID.setEnabled(false);
        btnActDeSystemID.setName("btnActDeSystemID"); // NOI18N
        btnActDeSystemID.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnActDeSystemIDMouseClicked(evt);
            }
        });

        btnActDeCategoryID.setText(resourceMap.getString("btnActDeCategoryID.text")); // NOI18N
        btnActDeCategoryID.setEnabled(false);
        btnActDeCategoryID.setName("btnActDeCategoryID"); // NOI18N
        btnActDeCategoryID.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnActDeCategoryIDMouseClicked(evt);
            }
        });

        btnAddSystemScheme.setText(resourceMap.getString("btnAddSystemScheme.text")); // NOI18N
        btnAddSystemScheme.setEnabled(false);
        btnAddSystemScheme.setName("btnAddSystemScheme"); // NOI18N
        btnAddSystemScheme.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnAddSystemSchemeMouseClicked(evt);
            }
        });

        btnAddCategory.setText(resourceMap.getString("btnAddCategory.text")); // NOI18N
        btnAddCategory.setEnabled(false);
        btnAddCategory.setName("btnAddCategory"); // NOI18N
        btnAddCategory.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnAddCategoryMouseClicked(evt);
            }
        });

        btnAddCategory2.setText(resourceMap.getString("btnAddCategory2.text")); // NOI18N
        btnAddCategory2.setActionCommand(resourceMap.getString("btnAddCategory2.actionCommand")); // NOI18N
        btnAddCategory2.setEnabled(false);
        btnAddCategory2.setName("btnAddCategory2"); // NOI18N
        btnAddCategory2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnAddCategory2MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TxtFile, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(statusPanelLayout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblBlank)
                                    .addComponent(lblSelect))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(btnReports, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnReturn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnPurchase, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnInit, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnActDeSystemID, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                            .addComponent(btnAddSystemScheme, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                            .addComponent(btnActDeCategoryID, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnAddCategory2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnAddCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(lblMessage))
                .addContainerGap(181, Short.MAX_VALUE))
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                .addContainerGap(167, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addComponent(btnInit)
                        .addGap(6, 6, 6)
                        .addComponent(btnPurchase)
                        .addGap(21, 21, 21)
                        .addComponent(btnReturn)
                        .addGap(19, 19, 19)
                        .addComponent(btnReports))
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addComponent(TxtFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(9, 9, 9)
                        .addComponent(lblBlank)
                        .addGap(21, 21, 21)
                        .addComponent(lblSelect)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnActDeSystemID, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnActDeCategoryID, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnAddSystemScheme, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnAddCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnAddCategory2, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(17, 17, 17)
                .addComponent(lblMessage)
                .addContainerGap())
        );

        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

   /*
    *The Initial button was clicked
    * if the file entered is returns true the
    * enable the other buttons and make them visible
    */
private void btnInitMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnInitMouseClicked
    //If read the Initalization file is true then enable the other buttons    
    String textFile = TxtFile.getText().toString();
    if (textFile.equals("") || textFile.equals("Enter File Name Here"))
    {
    btnInit.setEnabled(false);
    btnPurchase.setVisible(true);
    btnReturn.setVisible(true);
    btnReports.setVisible(true);
    btnPurchase.setEnabled(true);
    btnReturn.setEnabled(true);
    btnReports.setEnabled(true);
    btnInit.setVisible(false);
    btnActDeSystemID.setVisible(true);
    btnActDeCategoryID.setVisible(true);
    btnAddSystemScheme.setVisible(true);
    btnAddCategory.setVisible(true);
    btnActDeSystemID.setEnabled(true);
    btnActDeCategoryID.setEnabled(true);
    btnAddSystemScheme.setEnabled(true);
    btnAddCategory.setEnabled(true);
    btnAddCategory2.setEnabled(true);
    btnAddCategory2.setVisible(true);
    TxtFile.setVisible(false);    
    lblSelect.setVisible(true);    
    lblMessage.setText("");
    lblBlank.setText("");
    }
    else if (SystemInitialize.initialize(textFile))
    {
    btnInit.setEnabled(false);
    btnPurchase.setVisible(true);
    btnReturn.setVisible(true);
    btnReports.setVisible(true);
    btnPurchase.setEnabled(true);
    btnReturn.setEnabled(true);
    btnReports.setEnabled(true);
    btnActDeSystemID.setVisible(true);
    btnActDeCategoryID.setVisible(true);
    btnAddSystemScheme.setVisible(true);
    btnAddCategory.setVisible(true);
    btnActDeSystemID.setEnabled(true);
    btnActDeCategoryID.setEnabled(true);
    btnAddSystemScheme.setEnabled(true);
    btnAddCategory.setEnabled(true);
    btnAddCategory2.setEnabled(true);
    btnAddCategory2.setVisible(true);
    btnInit.setVisible(false);
    TxtFile.setVisible(false);
    lblSelect.setVisible(true);
    lblMessage.setText("");
    lblBlank.setText("");
    }
    else
    {
        lblMessage.setText("This file is not available.");
    }
}//GEN-LAST:event_btnInitMouseClicked

/*
 * The pruchase button was clicked. Go to the purchase screen
 */ 
//Unable to move brackets for autogenerated event declarations
private void btnPurchaseMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnPurchaseMouseClicked
    if (btnPurchase.isEnabled()==true)
    {        
    purchaseForm =  new Purchase();
    purchaseForm.setTitle("Purchase");
    purchaseForm.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    purchaseForm.setVisible(true);
    }
}//GEN-LAST:event_btnPurchaseMouseClicked

//Unable to move brackets for autogenerated event declarations
private void btnReturnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnReturnMouseClicked
    if (btnReturn.isEnabled() ==true)
    {
    returnForm =  new Return();
    returnForm.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    returnForm.setTitle("Return");
    returnForm.setVisible(true); 
    }
}//GEN-LAST:event_btnReturnMouseClicked

//Unable to move brackets for autogenerated event declarations
private void btnReportsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnReportsMouseClicked
    if (btnReports.isEnabled() ==true)
    {
    reportForm = new Reports();
    reportForm.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    reportForm.setTitle("Reports");
    reportForm.setVisible(true);
    }
}//GEN-LAST:event_btnReportsMouseClicked

private void btnActDeSystemIDMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnActDeSystemIDMouseClicked
 if ( btnActDeSystemID.isEnabled() == true)
 {
     stateSystem = new SetStateSystemPriceSchemeForm();
     stateSystem.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
     stateSystem.setTitle("Activate/Deactivate System Price Scheme");
     stateSystem.setVisible(true);
 }
}//GEN-LAST:event_btnActDeSystemIDMouseClicked

private void btnActDeCategoryIDMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnActDeCategoryIDMouseClicked
 if ( btnActDeCategoryID.isEnabled() == true)
 {
     stateCategory = new SetStateCategoryForm();
     stateCategory.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
     stateCategory.setTitle("Activate/Deactivate Category Price Scheme");
     stateCategory.setVisible(true);
 }
}//GEN-LAST:event_btnActDeCategoryIDMouseClicked

private void btnAddSystemSchemeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAddSystemSchemeMouseClicked
if ( btnAddSystemScheme.isEnabled() == true)
 {
     addSystemScheme = new AddSystemPriceSchemeForm();
     addSystemScheme.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
     addSystemScheme.setTitle("Add System Price Scheme");
     addSystemScheme.setVisible(true);
 }
}//GEN-LAST:event_btnAddSystemSchemeMouseClicked

private void btnAddCategoryMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAddCategoryMouseClicked
if ( btnAddCategory.isEnabled() == true)
 {
     addCategorySchemeOne = new AddCategoryPriceSchemeForm();
     addCategorySchemeOne.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
     addCategorySchemeOne.setTitle("Add Category Price Scheme One");
     addCategorySchemeOne.setVisible(true);
 }
}//GEN-LAST:event_btnAddCategoryMouseClicked

private void btnAddCategory2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAddCategory2MouseClicked
 if ( btnAddCategory2.isEnabled() == true)
 {
     addCategorySchemeTwo = new AddCategoryPriceSchemeTwoForm();
     addCategorySchemeTwo.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
     addCategorySchemeTwo.setTitle("Add Category Price Scheme Two");
     addCategorySchemeTwo.setVisible(true);
 }
}//GEN-LAST:event_btnAddCategory2MouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    javax.swing.JTextField TxtFile;
    javax.swing.JButton btnActDeCategoryID;
    javax.swing.JButton btnActDeSystemID;
    javax.swing.JButton btnAddCategory;
    javax.swing.JButton btnAddCategory2;
    javax.swing.JButton btnAddSystemScheme;
    javax.swing.JButton btnInit;
    javax.swing.JButton btnPurchase;
    javax.swing.JButton btnReports;
    javax.swing.JButton btnReturn;
    javax.swing.JLabel lblBlank;
    javax.swing.JLabel lblMessage;
    javax.swing.JLabel lblSelect;
    javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables

    //This section has been added
    private Purchase purchaseForm; 
    private Return returnForm;
    private Reports reportForm; 
    private SetStateSystemPriceSchemeForm stateSystem;
    private SetStateCategoryForm stateCategory;
    private AddSystemPriceSchemeForm addSystemScheme;
    private AddCategoryPriceSchemeForm addCategorySchemeOne;    
    private AddCategoryPriceSchemeTwoForm addCategorySchemeTwo;
}
